package com.balabala.gym_goods.service.impl;

import com.balabala.gym_goods.mapper.SpuMapper;
import com.balabala.gym_goods.pojo.dto.AppFindByNameDto;
import com.balabala.gym_goods.pojo.dto.SpuQueryDto;
import com.balabala.gym_goods.pojo.entity.Spu;
import com.balabala.gym_goods.pojo.vo.SpuListVo;
import com.balabala.gym_goods.service.SpuService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements SpuService {

    /**
     * 根据商品模糊查询
     * @param appFindByNameDto
     * @return
     */
    @Override
    public List<Spu> findByName(AppFindByNameDto appFindByNameDto) {
        LambdaQueryWrapper<Spu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.like(Spu::getName, appFindByNameDto.getName());
        return getBaseMapper().selectList(lambdaQueryWrapper);
    }
    //根据商品id查询商品信息
    @Override
    public Spu findGoodInfoById(Long id) {
        return getBaseMapper().selectById(id);
    }

    //根据条件查询积分商城列表
    @Override
    public List<Spu> findListByDto(SpuQueryDto spuQueryDto) {
        return getBaseMapper().findListByDto(spuQueryDto);
    }

    @Override
    public List<SpuListVo> findSpuByQueryDto(SpuQueryDto spuQueryDto) {
        return getBaseMapper().findSpuByQueryDto(spuQueryDto);
    }

}
